package re.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Audience {

    @Pointcut("execution(* re.service.i.IUserService.ids())")
    public void pointcutOfiIds() { }

    @Pointcut("execution(* re.service.i.IUserService.delById(int)) && args(id)")
    public void pointcutOfDelById(int id) { }

    @Before("pointcutOfiIds()")
    public void logBefore() {
        System.out.println("before call ids");
    }

    @After("pointcutOfiIds()")
    public void logAfter() {
        System.out.println("after call ids");
    }

    @Around("pointcutOfDelById(id)")
    public void loghasArg(ProceedingJoinPoint jp, int id) throws Throwable {
        System.out.println("touch user has id: " + id);
        jp.proceed(new Object[] { id });
    }
}
